home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 10
/
010.d81
/
pps #22
< prev
next >
Wrap
Text File
|
2022-08-26
|
4KB
|
259 lines
PEEKs, POKEs, and SYSes -- Part 22
by Alan Gardner
======================================
Location: 1024-2023 Hex:$0400-07E7
Official Label:VICSCN Type: RAM
Useful BASIC commands: PEEK, POKE
--------------------------------------
These 1000 locations are known
collectively as your text screen.
You are now 'looking' at all of these
locations. Your text screen is like
a window into memory. It just so
happens that your C-64 defaults to
locations 1024-2023.
The locations start in the upper-
left hand corner and proceed across
the screen. When you reach the right
side, you merely go back to the left
side, one line lower. It's just like
reading a book.
Now you might wonder what the
importance of all this is. Well,
suppose you needed to scroll your
screen. Sound easy enough? Well, how
about scrolling left or right? This
is where knowing about your text
screen comes in handy.
Now lets take scrolling left first.
We want a routine to take information
and slide it to the left. First of
all, we need to know that our screen
is 40 characters across and 25 lines
tall. Let's draw a picture of a bit
of our text screen.
!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!
!1024 !1025 !1026 !1027 !.... !
! ! ! ! ! !
!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!
!1064 !1065 !1066 !1067 !.... !
! ! ! ! ! !
{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
Now what we want to do is this:
1. Take what is in location 1024
off of the screen.
2. Move what is in location 1025
into location 1024.
3. Move what is in location 1026
into location 1025
4. Etc...
5. Move what is in location 1064
off of the screen.
6. Move what is in location 1065
into location 1064.
7. Move what is in location 1066
into location 1065
8. Etc.... Until we move what is
in location 2023 into location
2022.
You might notice that if the location
is on the left side of the screen, we
move it off completely. But what
about the locations on the far right
of the screen? Well, we'll just fill
them with spaces.
Now that you're thoroughly confused..
There are many different ways to
approach this task. Here is one of
them:
First set a variable equal to the
base address of our text screen.
10 BA=1024 : REM base address
Next, we'll have to have two loops.
One loop is for going across the
screen, and the other loop is for
going down the screen.
20 FOR Y=0to24 : REM down screen
30 FOR X=0to38 : REM across screen
You might have noticed that we are
only going across for 39 characters
(0-38 is 39 characters). This is
because we want to store a space in
the right-most location on each line.
Now a formula for calculating where
we are on the screen is:
ADDRESS=BA+40*Y+X
Y is the number of lines down and
X is the number of spaces across.
40 ADDR=BA+40*Y+X : REM where are we?
Now that we know where we are, we
can find out what is there and then
put it in the right place. Because
we are scrolling left, we want to
'look ahead' at the next location to
find out what to put in the current
location (make sense?). Well, if
you're a bit confused, take another
look at the diagram way up at the
beginning, and then look at the 8
steps which we want to follow. Now
when I say we want to move the
contents of the left-most locations
off the screen, this does not mean
that we have to pick them up and move
them. Why not just move the right
thing into them? Here is the rest
of the program with some more
description:
50 POKE ADDR, PEEK(ADDR+1)
60 NEXT X
70 POKE ADDR+1,32
80 NEXT Y
Line 50 is the main step in our
program. What it does is pick up what
is in one location and put it into
the location directly to the left of
it. For example, it takes out what
is in location 1025 and puts what
it finds into 1024. This produces our
scroll left effect. Line 70 is to put
a space in the right-most locations.
A 32 is the ASCII value for a space.
That's all there is to this small
scroll left program. It works a
little slow, but that's the price
you pay for using BASIC. You may
notice one small problem with this
routine. If you have characters of
different colors on your screen, the
colors can really get messed up!
Well....check out Part 23!
------- continued in Part 23 ---------